home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / comms / other / ascan / sources / br.rexx < prev    next >
OS/2 REXX Batch file  |  1999-06-14  |  3KB  |  120 lines

  1. /* my bumprev.rexx */
  2.  
  3. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  4. l="rexxsupport.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  5.  
  6. prg=programName("NOEXT")
  7.  
  8. if ~RMH_ReadArgs("FILE/A,VER=VERSION/K/N,REV=REVISION/K/N,NA=NOASM/S,MR=MAXREV/N") then do
  9.     call printFault(IoErr(),prg)
  10.     exit
  11. end
  12.  
  13. if parm.1.flag then
  14.     if parm.1.value<0 then call err "bad VER value '"parm.1.value"'"
  15.     else ver=parm.1.value
  16. else ver=-1
  17.  
  18. if parm.2.flag then
  19.     if parm.2.value<0 then call err "bad REV value '"parm.2.value"'"
  20.     else rev=parm.2.value
  21. else rev=-1
  22.  
  23. if parm.4.flag then
  24.     if parm.4.value<10 then call err "bad MR value '"parm.4.value"'"
  25.  
  26. app=parm.0.value
  27. hf=app"_rev.h"
  28. if=app"_rev.i"
  29.  
  30. if ver==-1 | rev==-1 then do
  31.     if open("IN",hf,"R") then do
  32.         v=""
  33.         r=""
  34.         do while ~eof(in)
  35.             line=readln(in)
  36.             if line="" then iterate
  37.             line=translate(line," ","9"x)
  38.             parse var line "#define VERSION" d .
  39.             if d~="" then v=d
  40.             else do
  41.                 parse var line "#define REVISION" d .
  42.                 if d~="" then r=d
  43.             end
  44.             if v~="" & r~="" then leave
  45.         end
  46.  
  47.         call close("IN")
  48.  
  49.         if r~="" then
  50.             if dataType(r,"N") & r>0 then do
  51.                 if rev=-1 then
  52.                     if ver=-1 then rev=r+1
  53.                     else rev=r
  54.             end
  55.             else call err "bad REV value '"r"' found in file '"hf"'"
  56.  
  57.         if v~="" then
  58.             if dataType(v,"N") & v>0 then do
  59.                 if ver=-1 then ver=v
  60.             end
  61.             else call err "bad VER value '"v"' found in file '"hf"'"
  62.  
  63.     end
  64.     else do
  65.         ver=0
  66.         rev=1
  67.     end
  68. end
  69.  
  70. if parm.4.flag then
  71.     if rev>=parm.4.value then do
  72.         ver=ver+1
  73.         rev=1
  74.     end
  75.  
  76. tab="9"x
  77. tabtab=tab||tab
  78. date=formatDate(,"%d %m %y")
  79. parse var date d m y .
  80. d=d+1-1
  81. m=m+1-1
  82. date = d"."m"."y
  83.  
  84. if ~open("OUT",hf,"W") then call err "can't open '"hf"' for output"
  85. call writeln("OUT","#define PRG"tabtab||tab||'"'app'"')
  86. call writeln("OUT","#define VERSION"tabtab||ver)
  87. call writeln("OUT","#define REVISION"tab||rev)
  88. call writeln("OUT","#define DATE"tabtab||'"'date'"')
  89. call writeln("OUT","#define VERS"tabtab||'"'app ver"."rev'"')
  90. call writeln("OUT","#define VSTRING"tabtab||'"'app ver"."rev "("date")\r\n"'"')
  91. call writeln("OUT","#define VERSTAG"tabtab'"'"\0$VER: "app ver"."rev "("date")"'"')
  92. call close("OUT")
  93.  
  94. if ~parm.3.flag then do
  95.     if ~open("OUT",if,"W") then call err "can't open '"hi"' for output"
  96.     call writeln("OUT","VERSION EQU" ver)
  97.     call writeln("OUT","REVISION EQU" rev)
  98.     call writeln("OUT","DATE MACRO")
  99.         call writeln("OUT",tab"dc.b" "'"date"'")
  100.     call writeln("OUT",tab"ENDM")
  101.     call writeln("OUT","VERS MACRO")
  102.         call writeln("OUT",tab"dc.b" "'"app ver"."rev"'")
  103.     call writeln("OUT",tab"ENDM")
  104.     call writeln("OUT","VSTRING MACRO")
  105.         call writeln("OUT",tab"dc.b" "'"app ver"."rev "("date")',13,10,0")
  106.     call writeln("OUT",tab"ENDM")
  107.     call writeln("OUT","VERSTAG MACRO")
  108.         call writeln("OUT",tab"dc.b" "'"app ver"."rev "("date")',0")
  109.     call writeln("OUT",tab"ENDM")
  110.     call close("OUT")
  111. end
  112.  
  113. say "Bumped file '"app"' to" ver"."rev
  114. exit
  115.  
  116. err: procedure expose prg
  117. parse arg msg
  118.     say prg":" msg
  119.     exit
  120.